<?php defined('_JEXEC') or die('Restricted access'); ?> 
<?php $edit=JRequest::getVar( 'edit', true );?>
<?php $this->_ToolbarEdit($edit, $this->cid);?>
<?php $type = $this->tmpl->type; if (!$edit) $type='0'; ?>
<div id="janews-main">

		<script language="javascript" type="text/javascript">
		<!--
		var templates = new Array();
		<?php 
  		$i = 0;
  		foreach ($this->templates as $arr) {
  			echo "templates[".$i++."] = new Array( '$arr[0]','".addslashes( $arr[1] )."','".addslashes( $arr[2] )."' );\t";
  		}
		?>
		//-->
		</script>

<script language="javascript" type="text/javascript">
	function submitbutton(pressbutton) {
		var form = document.adminForm;
		if (pressbutton == 'cancel') {
			submitform( pressbutton );
			return;
		}
		// do field validation
		form.title.value = trim(form.title.value);
		if (form.title.value == ""){
			alert( "<?php echo JText::_( 'YOUR LAYOUT TEMPLATES MUST CONTAIN A TITLE', true ); ?>" );
		} else if (form.tmpl_type.value == "0"){
			alert( "<?php echo JText::_( 'YOUR LAYOUT TEMPLATES MUST HAVE A TYPE TEMPLATE', true ); ?>" );
		}	else if (!form['params[listofhlcontent]']) {
		  submitform(pressbutton);
		}	else if (form['params[listofhlcontent]'][2].checked && form['params[hlarticles_id]'].value == ""){
		  alert( "<?php echo JText::_( 'THE LIST OF HEADLINE CONTENT MUST HAVE A ARTICLE ID', true ); ?>" );
		} else {
			submitform( pressbutton );
		}
	}
</script>
<form action="index.php" method="post" name="adminForm" id="adminForm">
<div class="col width-50">
	<fieldset class="adminform">
		<legend><?php echo JText::_( 'Details' ); ?></legend>
		<table class="admintable">
		<tr>
			<td width="100" align="right" class="key">
				<label for="title">
					<?php echo JText::_( 'TEMPLATES TITLE' ); ?>:
				</label>
			</td>
			<td>
				<input class="inputbox" type="text" name="title" id="title" maxlength="50" size="50" value="<?php echo $this->tmpl->title; ?>" />
			</td>
		</tr>
		<tr>
			<td width="100" align="right" class="key">
				<label for="title">
					<?php echo JText::_( 'TEMPLATE TYPE' ); ?>:
				</label>
			</td>
			<?php $javascript = "onchange=\"changeDynaList( 'template', templates, document.adminForm.tmpl_type.options[document.adminForm.tmpl_type.selectedIndex].value, 0, 0);\"";?>
			<td>
			<?php if (!$edit): ?>
			<?php echo JHTML::_( 'select.genericlist', $this->tmpl_type, 'tmpl_type', 'size="1" class="inputbox" '.$javascript, 'value', 'text',$type);?>
			<?php else: ?>
			 <input class="inputbox" type="text" name="tmpl_type" id="tmpl_type" readonly="true" value="<?php echo $type; ?>" />
			<?php endif; ?>
			</td>
		</tr>
		<tr>
		<td width="100" align="right" class="key">
		  <label for="title">
					<?php echo JText::_( 'TEMPLATE' ); ?>:
			</label>
		</td>
		<td>
		<?php if (!$edit): ?>		
      <select name="template" class="inputbox" size="1">
        <option value="<?php echo $type;?>"><?php echo $this->tmpl->template; ?></option>
      </select>
    <?php else: ?>
      <input class="inputbox" type="text" name="template" id="template" size="50" readonly="true" value="<?php echo $this->tmpl->template; ?>" />
    <?php endif; ?>
		</td>
		</tr>
	</table>
	</fieldset>

<?php if ($edit): ?>
	<fieldset class="adminform">
		<legend><?php echo JText::_( 'PARAMETERS' ); ?></legend>

		<table class="admintable">
		<tr>
			<td colspan="2">
				<?php echo $this->params->render('params');?>
			</td>
		</tr>
		</table>
	</fieldset>
<?php endif; ?>
</div>
<div class="clr"></div>
<input type="hidden" name="option" value="com_janews" />
<input type="hidden" name="cid" value="<?php echo $this->cid; ?>" />
<input type="hidden" name="group" value="<?php echo $this->group; ?>" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="controller" value="layouttemplates" />
<?php echo JHTML::_( 'form.token' ); ?>
</form>
</div>